import { BasicColumn, FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '标题',
    width: 150,
    dataIndex: 'noticeTitle',
  },
  {
    title: '消息类型',
    dataIndex: 'noticeType',
    width: 100,
    customRender: ({text}) => {
        return  render.renderDict(text, 'notice_type')
    },
  },
  {
    title: '公告内容',
    width: 200,
    dataIndex: 'noticeContent',
  },
  {
    title: '发布人',
    width: 100,
    dataIndex: 'createdBy',
  },

  {
    title: '状态',
    dataIndex: 'status',
    width: 60,
    customRender: ({text}) => {
      const color = text== '1' ? 'red': text == '0' ?'green':'gray';
      return  render.renderTag(render.renderDict(text, 'notice_status'),color)
    }
  },
  {
    title: '发布时间',
    width: 160,
    dataIndex: 'createdAt',
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'noticeTitle',
    label: '标题',
    component: 'JInput',
    colProps: {span: 8},
  }
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: 'id',
    component: 'Input',
    show:false
  },
  {
    field: 'noticeType',
    label: '消息类型',
    required: true,
    component: 'JDictSelectTag',
    defaultValue:'1',
    componentProps: {
      type:'radio',
      dictCode:'notice_type',
      placeholder:'请选择类型',
    },
  },
  {
    field: 'noticeTitle',
    label: '标题',
    component: 'Input',
    required: true,
    componentProps: {
      placeholder: '请输入标题',
    }
  },
  {
    field: 'noticeContent',
    label: '内容',
    component: 'InputTextArea',
    // render: render.renderTinymce,
  },
  {
    field: 'remark',
    label: '摘要',
    component: 'InputTextArea',
    required: true
  }
];


export const formDetailSchema = [
  {
    field: 'noticeTitle',
    label: '标题'
  },
  {
    field: 'createdBy',
    label: '发布人'
  },
  {
    field: 'noticeType', 
    label: '消息类型',
    render: (curVal, data) => {
      return render.renderDict(curVal, 'notice_type')
    },
  },
  {
    field: 'noticeContent',
    label: '公告内容',
    contentStyle: {             
      maxWidth: '500px',
      wordBreak: 'break-all',
      wordWrap: 'break-word'
    },
    span: 1
  },
  {
    field: 'status',
    label: '状态',
    render: (curVal, data) => {
      const color = curVal== '1' ? 'red': curVal == '0' ?'green':'gray';
      return render.renderTag(render.renderDict(curVal, 'notice_status'),color)
    },
  },
  {
    field: 'createdAt',
    label: '发布时间'
  }
];
